//获取应用实例
const app = getApp()
Page({
	data: {
		signnumtext:"",
		signnum:['1人', '2人'],
		namevalue:'',
		phonevalue:'',
		acid:''
	},
	onLoad:function(option){
		this.setData({
			acid:option.acid
		})
	},
	//事件处理函数	
	bindNumChange:function(e){
		this.setData({
			signnumtext:this.data.signnum[e.detail.value]
		})
	},
	nameInput:function(e){
		this.setData({
			namevalue:e.detail.value
		})
	},
	phoneInput:function(e){
		this.setData({
			phonevalue:e.detail.value
		})
	},
	trueSubmit:function(e){	
		if(!this.data.namevalue){
			wx.showToast({
				title:'请输入姓名',
				icon:'none'
			})
			return false;
		}
		if(!this.data.phonevalue){
			wx.showToast({
				title:'请输入手机号',
				icon:'none',
			})
			return false;
		}
		if(this.data.phonevalue.length != 11){
			wx.showToast({
				title:'请输入正确的手机号',
				icon:'none'
			})
			return false;
		}
		/*
		if(!this.data.signnumtext){
			wx.showToast({
				title:'请选择报名人数',
				icon:'none'
			})
			return false;
		}*/
		var that = this;
		app.request('/api/Member/activeSignin', {phone:this.data.phonevalue,name:this.data.namevalue,challengeid:this.data.acid}, function(res){
			wx.showToast({
				title:res.msg,
				icon:'none'
			})
			if(res.code == '0'){
				setTimeout(function(){
					wx.navigateTo({
						url:'/pages/activitylist/activitylist'						
					})
				}, 1500);
			}
		});
	}
})